package com.shunhe.shyqfk.base;

import android.text.TextUtils;

import com.google.gson.Gson;
import com.ruitu.arad.api.okhttp.MyOkHttp;
import com.ruitu.router_module.Config;

import java.util.concurrent.TimeUnit;

import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;

public class Gl {

    public static final String DATE_FORMATE_1 = "yyyy-MM-dd HH:mm:ss";

    public static MyOkHttp okHttp;
    private static HttpLoggingInterceptor logInterceptor;
    public static Gson gson = new Gson();

    {
        logInterceptor = new HttpLoggingInterceptor();//创建拦截对象
        if (Config.IS_DEBUG) {
            logInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);// 这句一定要写,否则没有数据输出
        } else {
            logInterceptor.setLevel(HttpLoggingInterceptor.Level.NONE);
        }
        //自定义OkHttp
        OkHttpClient okHttpClient = new OkHttpClient.Builder()
                .connectTimeout(10000L, TimeUnit.MILLISECONDS)
                .readTimeout(10000L, TimeUnit.MILLISECONDS)
                .addInterceptor(logInterceptor)
                .build();
        okHttp = new MyOkHttp(okHttpClient);
    }

    // 根据园区代码获取园区名称
    // 1 天源一期 2 天源二期 3 天源三期 4 顺和物流园
    public static String getParkByCode(String code) {
        if (TextUtils.equals("1", code)) {
            return "天源一期";
        } else if (TextUtils.equals("2", code)) {
            return "天源二期";
        } else if (TextUtils.equals("3", code)) {
            return "天源三期";
        } else if (TextUtils.equals("4", code)) {
            return "顺和物流园";
        } else {
            return "顺和物流园";
        }

    }

}
